//
//  CuSetView.swift
//  onemeetingmac
//
//  Created by 张衡 on 2020/6/16.
//  Copyright © 2020 onemeeting. All rights reserved.
//

import Foundation

class CuSetView: NSView {
    var cusView:NSView?
    var cusSize:CGSize = CGSize.zero
    var text:String = "会议模式"
    
    var titleWidth:CGFloat = 160 {
        didSet {
            self.title.snp.updateConstraints { (make) in
                make.width.equalTo(titleWidth)
            }
        }
    }
    
    override init(frame frameRect: NSRect) {
        super.init(frame: frameRect)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    convenience init(text:String,cusView:NSView?,cusSize:CGSize=CGSize.init(width: 180, height: 26)) {
        self.init()
        self.text = text
        self.cusView = cusView
        self.cusSize = cusSize
        self.setupUI()
    }
    
    
    func setupUI() {
        self.addSubview(title)
        title.snp.makeConstraints { (make) in
            make.width.equalTo(titleWidth)
            make.height.equalTo(18)
            make.top.equalTo(3)
            make.left.equalToSuperview()
        }
        
        if let customView = self.cusView {
            self.addSubview(customView)
            customView.snp.makeConstraints { (make) in
                make.left.equalTo(self.title.snp.right).offset(10)
                make.top.equalTo(2)
                make.size.equalTo(cusSize)
            }
        }
    }
    
    lazy var title: NSLabel = {
        let lab = NSLabel.label(title: self.text, textColor: color_gray(80), font: NSFont.systemFont(ofSize: 14))
        lab.alignment = .right
        return lab
    }()
    
    
}
